package com.atguigu.tingshu.user.api;

import com.atguigu.tingshu.common.login.GuiguLogin;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.user.service.UserInfoService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "用户管理接口")
@RestController
@RequestMapping("api/user/userInfo")
@SuppressWarnings({"unchecked", "rawtypes"})
public class UserInfoApiController {

	@Autowired
	private UserInfoService userInfoService;



	/**
	 * 收藏当前声音
	 * @param trackId
	 * @return
	 */
	@GuiguLogin
	@GetMapping("/collect/{trackId}")
	public Result collect(@PathVariable("trackId") Long trackId){
		userInfoService.collect(trackId);
		return Result.ok();
	}

	/**
	 * 查询用户是否收藏当前声音
	 * @param trackId
	 * @return
	 */
	@GuiguLogin
	@GetMapping("/isCollect/{trackId}")
	public Result isCollect(@PathVariable("trackId") Long trackId){
		return Result.ok(userInfoService.isCollect(trackId));
	}
	/**
	 * 查询用户是否订阅当前专辑
	 * @param albumId
	 * @return
	 */
	// todo 前端没写订阅专辑接口
	@GuiguLogin
	@GetMapping("/isSubscribe/{albumId}")
	public Result isSubscribe(@PathVariable("albumId") Long albumId){
		return Result.ok(userInfoService.isSubscribe(albumId));
	}
}

